#!/usr/bin/env python3
# Created by han on 2016/6/21

import os,pickle,sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from module import maker,students
from conf import db_conf
COURSE_FILE = db_conf.DB_BASE+ "/" + "course.db"
TEACHER_FILE = db_conf.DB_BASE + "/" + "teacher.db"

a = [11,22,33,44]
ret = filter(lambda x:x>22,a)

def judge(name):
    """
    判断是否有这个老师
    :param name:将名称输入
    :return:返回真或假
    """
    with open(TEACHER_FILE, "rb") as teacher_file:
        teacher_obj_list = pickle.load(teacher_file)
    has_teacher = filter(lambda x:x.name == name, teacher_obj_list)
    print(has_teacher)


import time
def view_bar(num,total):
    rate = num/total
    rate_num = int(rate * 100)
    r1 ='\r%s>%d%%'%("="*num,rate_num)
    sys.stdout.write(r1)
    sys.stdout.flush()

for i in range(0,101):
    time.sleep(0.05)
    view_bar(i,100)

